<#--
Created by IntelliJ IDEA.
User: Alvin
Date: 2017/5/16
Time: 11:51
To change this template use File | Settings | File Templates.
-->
<#import "spring.ftl" as s />
<!DOCTYPE html>
<html lang="en">
<head>
    <title>登陆</title>
    <#--<link rel="stylesheet" type="text/css" href="css/style.css" />-->
    <link rel="stylesheet" type="text/css" href="js/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
    <script src="js/jquery-3.0.0.min.js"></script>
    <script src="js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <script>
        function login(){
            var username = document.getElementsByName("username")[0].value;
            var password = document.getElementsByName("password")[0].value;
            $.ajax({
                type:"POST",
                url: '/loginReq',
                data: "username="+username+"&password="+password,
                dataType:"text",
                async:true,
                success:function(data){
                    if(data == "success"){
                        console.log("login in:"+data);
                        window.location.href = "/index";
                    }else{
                        $("#title").val(data);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest.responseText);
                }
            });
        }
    </script>
</head>
<body>
    <div id="title" style="height:100px;"></div>
    <div class="container" style="width:500px;">
        <h3 class="text-center">登陆</h3>
        <div class="login-block ">
            <div class="from-group">
                <input type="text" class="form-text form-control" name="username" placeholder="手机号/邮箱">
            </div>
            <div class="from-group">
                <input type="password" class="form-text form-control" name="password" placeholder="密码">
            </div>
            <div>
                <input type="submit" class="btn btn-primary btn-block" name="login" value="登陆" onclick="login();">
            </div>
        </div>
    </div>
</body>
</html>
